package us.x.slowexp.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import us.x.slowexp.domain.Administrator;
import us.x.slowexp.domain.Express;
import us.x.slowexp.domain.Page;
import us.x.slowexp.service.LoginService;
import us.x.slowexp.service.PageExpressService;

@Controller
public class LoginAction {
	
	@Autowired
	private LoginService loginService;
	@Autowired
	private PageExpressService pageExpressService;
	
	@RequestMapping("/login.action")
	public String login(Administrator administrator, HttpServletRequest req, Model model){
		Administrator exist = this.loginService.login(administrator);
		
		if(exist != null){
			req.getSession().setAttribute("administrator", exist);
			return "redirect:/list.action";
		}else{
			return "error";
		}
	}
}
